home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 December / DPPCPRO1205.ISO / Essentials / Programming / Basic4GL / Setup Basic4GL v2.3.1.exe / $INSTDIR / Programs / nehe11.gb < prev    next >
Encoding:
Text File  |  2005-07-29  |  4.4 KB  |  108 lines

  1. dim points#(45)(45)(3)      ' The Array For The Points On The Grid Of Our "Wave"
  2. dim wiggle_count            ' Counter Used To Control How Fast Flag Waves
  3. wiggle_count = 0
  4.  
  5. dim xrot#                   ' X Rotation ( NEW )
  6. dim yrot#                   ' Y Rotation ( NEW )
  7. dim zrot#                   ' Z Rotation ( NEW )
  8. dim hold#                   ' Temporarily Holds A Floating Point Value
  9.  
  10. dim texture                 ' Storage For One Texture ( NEW )
  11.  
  12. dim float_x#, float_y#, float_xb#, float_yb#
  13.  
  14.  
  15. dim x, y
  16.  
  17.     ' Load Bitmaps
  18.     texture = LoadTexture ("Data/Tim.bmp")
  19.     glBindTexture (GL_TEXTURE_2D, texture)
  20.     glBindTexture(GL_TEXTURE_2D, texture)
  21.     glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
  22.     glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
  23.  
  24.     glEnable(GL_TEXTURE_2D)                             ' Enable Texture Mapping ( NEW )
  25.     glShadeModel(GL_SMOOTH)                             ' Enable Smooth Shading
  26.     glClearColor(0.0, 0.0, 0.0, 0.5)                    ' Black Background
  27.     glClearDepth(1.0)                                   ' Depth Buffer Setup
  28.     glEnable(GL_DEPTH_TEST)                             ' Enables Depth Testing
  29.     glDepthFunc(GL_LEQUAL)                              ' The Type Of Depth Testing To Do
  30.     glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)   ' Really Nice Perspective Calculations
  31.     glPolygonMode( GL_BACK, GL_FILL )                   ' Back Face Is Solid
  32.     glPolygonMode( GL_FRONT, GL_LINE )                  ' Front Face Is Made Of Lines
  33.  
  34.     glEnable(GL_TEXTURE_2D)                             ' Enable Texture Mapping ( NEW )
  35.     glShadeModel(GL_SMOOTH)                             ' Enable Smooth Shading
  36.     glClearColor(0.0, 0.0, 0.0, 0.5)                    ' Black Background
  37.     glClearDepth(1.0)                                   ' Depth Buffer Setup
  38.     glEnable(GL_DEPTH_TEST)                             ' Enables Depth Testing
  39.     glDepthFunc(GL_LEQUAL)                              ' The Type Of Depth Testing To Do
  40.     glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)   ' Really Nice Perspective Calculations
  41.     glPolygonMode( GL_BACK, GL_FILL )                   ' Back Face Is Solid
  42.     glPolygonMode( GL_FRONT, GL_LINE )                  ' Front Face Is Made Of Lines
  43.  
  44.     for x = 0 to 44
  45.         for y = 0 to 44
  46.             points#(x)(y)(0)=(x/5.0)-4.5
  47.             points#(x)(y)(1)=(y/5.0)-4.5
  48.             points#(x)(y)(2)=sin((((x/5.0)*40.0)/360.0)*3.141592654*2.0)
  49.         next
  50.     next
  51.  
  52.     
  53.     ' Main loop
  54.     while true
  55.  
  56.         ' Here's Where We Do All The Drawing
  57.  
  58.         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)     ' Clear The Screen And The Depth Buffer
  59.         glLoadIdentity()                                        ' Reset The View
  60.  
  61.         glTranslatef(0.0,0.0,-12.0)
  62.       
  63.         glRotatef(xrot#,1.0,0.0,0.0)
  64.         glRotatef(yrot#,0.0,1.0,0.0)  
  65.         glRotatef(zrot#,0.0,0.0,1.0)
  66.  
  67.         glBindTexture(GL_TEXTURE_2D, texture)
  68.  
  69.         glBegin(GL_QUADS)
  70.         for x = 0 to 43
  71.             for y = 0 to 43
  72.                 float_x# = (x)/44.0
  73.                 float_y# = (y)/44.0
  74.                 float_xb# = (x+1)/44.0
  75.                 float_yb# = (y+1)/44.0
  76.                     
  77.                 glTexCoord2f( float_x#, float_y#)
  78.                 glVertex3f( points#(x)(y)(0), points#(x)(y)(1), points#(x)(y)(2) )
  79.  
  80.                 glTexCoord2f( float_x#, float_yb# )
  81.                 glVertex3f( points#(x)(y+1)(0), points#(x)(y+1)(1), points#(x)(y+1)(2) )
  82.  
  83.                 glTexCoord2f( float_xb#, float_yb# )
  84.                 glVertex3f( points#(x+1)(y+1)(0), points#(x+1)(y+1)(1), points#(x+1)(y+1)(2) )
  85.  
  86.                 glTexCoord2f( float_xb#, float_y# )
  87.                 glVertex3f( points#(x+1)(y)(0), points#(x+1)(y)(1), points#(x+1)(y)(2) )
  88.             next
  89.         next
  90.         glEnd()
  91.         SwapBuffers ()
  92.                       
  93.         if wiggle_count = 2 then
  94.             for y = 0 to 44
  95.                 hold#=points#(0)(y)(2)
  96.                 for x = 0 to 43
  97.                     points#(x)(y)(2) = points#(x+1)(y)(2)
  98.                 next
  99.                 points#(44)(y)(2) = hold#
  100.             next
  101.             wiggle_count = 0
  102.         endif
  103.         wiggle_count = wiggle_count + 1              
  104.  
  105.         xrot# = xrot# + 0.3
  106.         yrot# = yrot# + 0.2
  107.         zrot# = zrot# + 0.4
  108.     wend